package com.me.mygdxgame;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.me.ultilities.DrawComponent;

public class PigAnimation {
	private TextureRegion[] regionState1;
	private TextureRegion[] regionState2;
	private int status;
	private float x;
	private float y;
	private boolean isLocked = false;
	private float stateToDead = 0;

	public PigAnimation() {
		regionState1 = new TextureRegion[6];
		for (int i = 0; i < 6; i++) {
			regionState1[i] = new TextureRegion(new Texture(
					Gdx.files.internal("animation/a" + (i + 1) + ".png")));
		}
		regionState2 = new TextureRegion[3];
		for (int i = 0; i < 3; i++) {
			regionState2[i] = new TextureRegion(new Texture(
					Gdx.files.internal("animation/kill" + (i + 1) + ".png")));
		}
		setStatus(1);
	}

	public boolean isLocked() {
		return isLocked;
	}

	public void setLocked(boolean isLocked) {
		this.isLocked = isLocked;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}

	public void start(DrawComponent draw, SpriteBatch spriteBatch,
			Animation animation, float stateTime, float index) {
		switch (status) {
		case 1: {
			setX(10 + index);
			setY(60);
			draw.drawAnimation(0.25f, animation, stateTime, regionState1,
					spriteBatch, getX(), getY(), true);

			break;
		}
		case 2: {
			draw.drawAnimation(1.5f, animation, stateTime, regionState2,
					spriteBatch, getX(), getY(), false);
			stateToDead += Gdx.graphics.getDeltaTime();
			if (stateToDead > 2.5)
				setStatus(3);
			break;
		}
		case 3: {
			break;
		}
		}
	}
}
